var page = sm("do_Page");
var app = sm("do_App");
var storage = sm("do_InitData");
var open = require("open");
var nf = sm("do_Notification");
var rootview = ui("$");
var buttonA = mm("do_Animation", "BUTTONTOUCHDOWNS", "app");
var param = {oneCategory:[],oneSelected:{}};

//遮罩显示
var animMaskShow = mm("do_Animator");
var propsMS = {bgColor:"00000077"};
animMaskShow.append(300,propsMS,"EaseOut");
//面板显示
var animPanelShow = mm("do_Animator");
var propsPS = {y:460};
animPanelShow.append(300,propsPS,"Linear");
//遮罩隐藏
var animMaskHide = mm("do_Animator");
var propsMH = {bgColor:"00000000"};
animMaskHide.append(300,propsMH,"EaseIn");
//面板隐藏
var animPanelHide = mm("do_Animator");
var propsPH = {y:960};
animPanelHide.append(300,propsPH,"EaseIn");

//遮罩事件
var maskbg = ui("bgmask");
maskbg.on("touch","",300,function(){
	maskbg.animate(animMaskHide,function(){
		maskbg.visible = false;
	});
	bodyp.animate(animPanelHide);
});
//防止穿透
var bodyp = ui("pbody");
bodyp.on("touch","",300,function(){
	
});
var labelTitle = ui('do_Label_title');
var isId0 = '';
//确定  
var surebtn = ui("do_Button_sure");
surebtn.on("touch","",300,function(){
	if(param.oneSelected!=""){
		var isData0 = [param.oneSelected,isId0];
		page.fire("refreshOneCategory",isData0);
	}
	maskbg.animate(animMaskHide,function(){
		maskbg.visible = false;
	});
	bodyp.animate(animPanelHide);
});
//zdy
page.on("oneCategory",function(data){
	maskbg.visible = data;
	maskbg.animate(animMaskShow);
	bodyp.animate(animPanelShow);
});

var oneCategorypick = ui("do_Picker_oneCategory");
var oneCategorydate = mm("do_ListData");
page.on("oneCategoryList",function(data){
	var pTitle = data[0].title;
	isId0 = data[0].id;
	labelTitle.text = pTitle;
	var datas = data[1];
	param.oneCategory=data[1];
	oneCategorydate.removeAll();
	var bCategory = [];
	for(var i=0,length=datas.length;i<length;i++){
		bCategory[i] = datas[i].name;
	}
	oneCategorydate.addData(bCategory);
	oneCategorypick.bindItems(oneCategorydate);
	oneCategorypick.refreshItems();
	param.oneSelected.oneid = datas[0].id;
	param.oneSelected.onename = datas[0].name;
});
//滑动
oneCategorypick.on("selectChanged",function(index){
	param.oneSelected.oneid = param.oneCategory[index].id;
	param.oneSelected.onename = param.oneCategory[index].name;
});
